from networkFramework import *
from framework import *
from dataStruct import quoteStruct as qStruct
import time

def main():
    configData = getQSConfig()
    if len(sys.argv) == 3:
        host = sys.argv[1]
        port = sys.argv[2]
    else:
        host = configData['host']
        port = configData['port'] 
        
    timer = time.time()
    quoteObj = qStruct()
    buffSize = quoteObj.buffSize
    qRecSock = reciverUDPConn(host, port, buffSize)

    
    while True:
        quoteObj = qStruct()
        quoteObj.buffer = qRecSock.recData()
        try:
            out = quoteObj.getValues()
            print out
        except:
            out = "Error: Timed out"
    
        if "EOF\x00" in out:
            break
    
    qRecSock.close()

if __name__ == "__main__":
    main()